Skip to content

lint against repeated repr attributes - #157036

Open
ettolrach wants to merge 15 commits into
rust-lang:mainfrom
ettolrach:disallow-repeated-reprs
Open

lint against repeated repr attributes#157036
ettolrach wants to merge 15 commits into
rust-lang:mainfrom
ettolrach:disallow-repeated-reprs

Conversation

@ettolrach

@ettolrach ettolrach commented May 27, 2026

Copy link
Copy Markdown

View all comments

fixes #156029 by adding a lint against repeated repr attributes.

r? scottmcm

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 27, 2026
@rust-log-analyzer

This comment has been minimized.

@traviscross traviscross added T-lang Relevant to the language team needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels May 27, 2026
@scottmcm

Copy link
Copy Markdown
Member

Wearing my lang hat but not speaking as team consensus (since we've not talked about it):

I think you should start with the "obviously good" version, and we can do future PRs later to expand it or to update severity. Concretely, thus, I'd say it should be a warning (because if it's inert it doesn't need to be deny) when you have a clearly-unnecessary one that wasn't emitted from a macro, or something like that.

(Our bar in the compiler for deny-by-default is pretty high. My personal heuristic is whether it's worth running your unit tests despite the warning, and an inert extra attribute doesn't need to block that.)

We can then look at impacts and ratchet it up over time or over an edition, but those decisions can be made later and don't need to block you making a useful lint in the meantime.


I'm a bad reviewer for lint stuff code-wise, though, so let's try
r? JonathanBrouwer

@rustbot rustbot assigned JonathanBrouwer and unassigned scottmcm May 30, 2026
@traviscross

Copy link
Copy Markdown
Contributor

+1 to what @scottmcm said on how best to approach this.

@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ettolrach
ettolrach marked this pull request as ready for review June 6, 2026 17:03
@rustbot

rustbot commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 6, 2026
@rustbot

This comment has been minimized.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jun 6, 2026
@ettolrach
ettolrach force-pushed the disallow-repeated-reprs branch from ae3cdee to 314903c Compare June 6, 2026 17:28
@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Jun 6, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor

r? jdonszelmann
I don't mind giving this one a look :)

@ettolrach
ettolrach force-pushed the disallow-repeated-reprs branch from d1a8d0d to 224a101 Compare July 28, 2026 10:16
@ettolrach

Copy link
Copy Markdown
Author

@jdonszelmann you've still got requested changes here (just in the UI, i did do the thing you wanted me to). it also doesn't look like this ping worked, so i guess i'll try it myself? though i don't think it'll go through. @rust-lang/lang

@scottmcm scottmcm added I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination labels Jul 28, 2026
@scottmcm

Copy link
Copy Markdown
Member

(Nominating to look at in triage tomorrow; sorry for the delay)

This adds a new repeated_reprs lint as warn-by-default that triggers on things like

#[repr(transparent)]
#[repr(transparent)]

Hopefully this is an easy accept because we'd talked about doing this in a previous meeting 🙂

@traviscross traviscross added the P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang label Jul 29, 2026
@traviscross

Copy link
Copy Markdown
Contributor

Looks OK to me modulo I'd expect this to go in the unused lint group.

@traviscross

Copy link
Copy Markdown
Contributor

Let's propose to do this modulo putting this in the unused lint group.

@rfcbot fcp merge lang

@rust-rfcbot

rust-rfcbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. and removed needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Jul 29, 2026
@tmandry

tmandry commented Jul 29, 2026

Copy link
Copy Markdown
Member

@rfcbot reviewed

@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Jul 29, 2026
@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jul 29, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[repr()] attribute has inconsistent handling of duplicates.

9 participants